/**
 * Created by Allan on 2017/09/20.
 */
import React, { Component } from "react";
import { getUrlParam } from "../../utils/common";
import { get } from "../../utils/db"
import "./index.less"

import {
  setTitle,
  setRight,
} from "../../utils/dingtalk";

export default class NoDataPage extends Component {
  constructor(props) {
    super(props);
    this.state = {
      fromFlag: 0,
      title: get("hrCenterPageLinkText") || decodeURI(getUrlParam("text"))
    }
    setTitle({
      title: get("hrCenterPageLinkText") || decodeURI(getUrlParam("text"))
    });
  }

  componentDidMount(){

  }

  componentWillMount() {
    const { title } = this.state;
    setRight({
      show: false
    });
    if (title.indexOf("待入职人员") !== -1) {
      this.setState({
        fromFlag: 1
      })
    }else if(title.indexOf("待离职员工") !== -1){
      this.setState({
        fromFlag: 2
      })
    }
  }

  gotoQrpage(){
    this.props.router.push("qrCode");
    //openLink('#/qrCode');
  }
  
  render() {
    const { fromFlag, title } = this.state;
    return (
      <div className="nodata-center">
        {
          fromFlag === 0 &&
          <div>
            <img src="https://gw.alicdn.com/tfs/TB1dNsVlMoQMeJjy1XaXXcSsFXa-144-124.png" alt=""/>
            <h4 className="nodata-center-normaltext">
              暂无{title}
            </h4>
          </div>
        }
        {
          fromFlag === 1 &&
          <div className="no-data">
            <img
              src="https://gw.alicdn.com/tfs/TB1CfRsmgMPMeJjy1XdXXasrXXa-174-204.png"
              alt=""
            />
            <p className="no-data-big-text">提前收集入职信息做好入职准备</p>
            <p className="no-data-small-text">当前暂无待入职员工</p>
            <p className="scanToAdd">
              <button
                onClick={() => {
                  openLink("#/qrCode");
                }}
              >
                扫码添加
              </button>
            </p>
          </div>
        }
        {
          fromFlag === 2 &&
          <div>
            <img src="https://gw.alicdn.com/tfs/TB1yKoCl3MPMeJjy1XdXXasrXXa-116-132.png" alt=""/>
            <div className="nodata-center-normaltext">
              及时获悉离职申请，保障企业信息安全
            </div>
            <div className="nodata-center-smalltext">
              当前暂无待离职员工
            </div>
          </div>
        }
      </div>
    );
  }
}
